package ${package.Controller};

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.dxy.hms.base.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};

/**
* <p>
* ${table.comment!} controller
* </p>
*
* @author ${author}
* @since ${date}
*/
@Slf4j
@Api(tags = "${table.comment!}接口")
@RestController
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
public class ${table.controllerName} {

    @Autowired
    private ${table.serviceName} service;

    @ApiOperation("增加")
    @PostMapping("/add")
    public Resp add(@RequestBody ${entity} entity) {
        service.add(entity);
        return Resp.bizSuccess();
    }

    @ApiOperation("根据id修改")
    @PostMapping("/updById")
    public Resp updById(@RequestBody ${entity} entity) {
        service.updById(entity);
        return Resp.bizSuccess();
    }

<#-- 遍历字段列表以找到主键 -->
<#list table.fields as field>
<#if field.keyFlag>
    @ApiOperation("根据id删除")
    @PostMapping("/delByIds")
    public Resp delByIds(@RequestBody List<${field.propertyType}> ids) {
        service.delByIds(ids);
        return Resp.bizSuccess();
    }

    @ApiOperation("详情")
    @GetMapping("/getDetail")
    public Resp<${entity}> getDetail(${field.propertyType} id) {
        return Resp.bizSuccess(service.getDetail(id));
    }
    <#break>
</#if>
</#list>

    @ApiOperation("分页")
    @GetMapping("/getPage")
    public Resp<IPage<${entity}>> getPage(Long pageNum, Long pageSize) {
        return Resp.bizSuccess(service.getPage(pageNum, pageSize));
    }


}